// logs.js

Page({
  data: {
    logs: [],
    value: "",
    data: [],
    a: "",
    proinfo: {},
    pageNum: 1,
    pageSize: 50
  },
  click(event) {
    var _this = this
    // console.log(event.currentTarget.id)
    console.log(event.currentTarget.dataset.proinfo);
    _this.setData({
      value: event.currentTarget.id,
      proinfo: event.currentTarget.dataset.proinfo,
    })
    this.botton()
  },
  botton() {
    var _this = this
    getApp().globalData.seleproinfo = this.data.proinfo
    wx.navigateBack({ //返回
      delta: 1
    })
  },
  valueChange(e){
    if (e.detail.length  == 0) {
      this.setData({
        data:[],
        pageNum:1
      })
    }
  },
  onChange(event) {
    var _this = this
    _this.setData({
      value: event.detail,
      pageNum:1
    })

    if (_this.data.value.length >= 4) {
      wx.showLoading({
        title: '搜索中',
      })
      let prams = {
        corpName: event.detail,
        pageNum: this.data.pageNum,
        pageSize: this.data.pageSize
      }
      getApp().globalData.request('/financing/selectPageCorpByName', prams, "POST", ).then(res => {
        console.log("++++++++", res);
        wx.hideLoading()
        _this.setData({
          data: res.data.records
        })
      })
    }

  },
  getlist() {
    var _this = this
    if (_this.data.value.length >= 4) {
      wx.showLoading({
        title: '搜索中',
      })
      let prams = {
        corpName: this.data.value,
        pageNum: this.data.pageNum,
        pageSize: this.data.pageSize
      }
      getApp().globalData.request('/financing/selectPageCorpByName', prams, "POST", ).then(res => {
        console.log("++++++++", res);
        wx.hideLoading()
        _this.setData({
          data: this.data.data.concat(res.data.records)
        })
      })
    }
 
  },
  onReachBottom() {
    console.log(11);
    this.setData({
      pageNum: ++this.data.pageNum
    })
    this.getlist()
  },
  onLoad() {

  }
})